package org.yjc.service;

import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.yjc.entity.Grade;
import org.yjc.repository.GradeRepository;

@Service
public class GradeService {
	@Autowired
	private GradeRepository gradeDAO;

	public Grade findByStudentIdAndCourseId(Integer xs_id, Integer kc_id) {
		
		return gradeDAO.findByStudentIdAndCourseId(xs_id,kc_id);
	}

	public void save(Grade cj) {
		gradeDAO.save(cj);
		
	}

	public Grade findById(Integer id) {
		Optional<Grade> optional = gradeDAO.findById(id);
		if(optional.isPresent()) {
			return optional.get();
		}
		return null;
	}

}
